// JavaScript Document
//输入框提示
function inputTip(formclass, tipformclass) {
    var jsvalue = "";
    if ($.browser.msie)        // IE浏览器
    {
        $("." + formclass).get(0).onpropertychange = setJsUserName;
        $("." + tipformclass).get(0).onpropertychange = handle;
    }
    else        // 其他浏览器
    {
        var intervalName;        // 定时器句柄
        $("." + formclass).get(0).addEventListener("input", setValue, false);
        // 获得焦点时，启动定时器
        $("." + formclass).focus(function () {
            if ($("." + tipformclass).val() != "") {
                $("." + tipformclass).show();
            }
            intervalName = setInterval(handle, 10);
        });

        // 失去焦点时，清除定时器
        $("." + formclass).blur(function () {
            clearInterval(intervalName);
            $("." + tipformclass).hide();
        });
    }
    // 设置jsvalue input的值
    function setValue() {
        $("." + tipformclass).val($(this).val());
    }
    // jsUserName input的值改变时执行的函数
    function handle() {
        if ($("." + tipformclass).val() == "") {
            $("." + tipformclass).hide();
        }
        if ($("." + tipformclass).val() != jsvalue) {
            $("." + tipformclass).show();
            jsvalue = $("." + tipformclass).val();
        }
    }
}

//导航菜单
function navList(id) {
    var $obj = $("#nav_dot"), $item = $("#J_nav_" + id);
    $item.addClass("on").parent().removeClass("none").parent().addClass("selected");
    $obj.find("h4").hover(function () {
        $(this).addClass("hover");
    }, function () {
        $(this).removeClass("hover");
    });
    $obj.find("p").hover(function () {
        if ($(this).hasClass("on")) { return; }
        $(this).addClass("hover");
    }, function () {
        if ($(this).hasClass("on")) { return; }
        $(this).removeClass("hover");
    });
  
    $obj.find("h4").click(function () {
        var $div = $(this).siblings(".list-item");
        if ($(this).parent().hasClass("selected")) {
            $div.slideUp(50);
            $(this).parent().removeClass("selected");
          
        }
        if ($div.is(":hidden")) {
            $("#nav_dot li").find(".list-item").slideUp(50);
            $("#nav_dot li").removeClass("selected");
            $(this).parent().addClass("selected");
            $div.slideDown(50);

        } else {
            $div.slideUp(50);
        }
    });

    //页面点击跳转后，导航栏选中的样式  11-14
    $(".list-item a").each(function () {
        $this = $(this);
        if ($this[0].href == String(window.location)) {
            $this.parent().parent().addClass("selected")
            $this.parent().addClass("active");
            $(this).addClass('current')
        }
    });

}

//添加
function add() {
    $(".add_pop_box").show();
    $(".pop .colse_popbox").click(function () {
        $(".add_pop_box").hide();
    });
}

//修改
function modify(me) {    
    $(me).css("background-position", "-28px -103px");
    $(".modify_pop_box").show();
    $(".pop .colse_popbox").click(function () {
        $(".modify_pop_box").hide();
        $(".modify").css("background-position", "-28px -74px");
    });
}

//删除
function deletebox(me) {
    $(me).css("background-position", "-5px -105px");
    $(".delete_pop_box").show();
    $(".pop .colse_delbox").click(function () {
        $(".delete_pop_box").hide();
        $(".delete").css("background-position", "-4px -75px");
    });
}

//立即定购
function modify_buy(me) {
    $(me).css("background-position", "-28px -103px");
    $(".modify_pop_box").show();
    $(".pop .colse_popbox").click(function () {
        $(".modify_pop_box").hide();
        $(".modify").css("background-position", "-28px -74px");
    });
}

//销售备注框
function RemarkOrder_Js(me) {
    $(me).css("background-position", "-28px -103px");
    $(".RemarkOrder_box").show();
    $(".pop .colse_popbox").click(function () {
        $(".RemarkOrder_box").hide();
        $(".modify").css("background-position", "-28px -74px");
    });
}

//修改运费
function ModFreight_Js() {

    if (RoleID == 1 || RoleID == 2) {

        $(".ModFreight_box").show();

        $(".pop .colse_popbox").click(function () {
            $(".ModFreight_box").hide();
        });

    } else {
        alert("【运费】禁用");
    }
}

//作废订单
function CancelOrders_Js() {
    $(".CancelOrders_box").show();
    $(".pop .colse_popbox").click(function () {
        $(".CancelOrders_box").hide();
    });
}

//切换帐号
function SwitchID_Js() {
    $(".SwitchID_box").show();
    $(".pop .colse_popbox").click(function () {
        $(".SwitchID_box").hide();
    });
}

//出货框
function EditShip_Js() {
    $(".EditShip_box").show();
    $(".pop .colse_popbox").click(function () {
        $(".EditShip_box").hide();
    });
}

//批量修改所在地框
function Places_Js() {
    $(".ModPlace_box").show();
    $(".pop .colse_popbox").click(function () {
        $(".ModPlace_box").hide();
    });
}

//批量修改状态框
function Statuss_Js() {
    $(".ModStatus_box").show();
    $(".pop .colse_popbox").click(function () {
        $(".ModStatus_box").hide();
    });
}
 //退出
    function GetNotice() {
        $.ajax({
            url: "/Team/GetNotice",//提交地址
            type: "get",//提交方式
            data: "",
            contentType: "application/json; charset=utf-8",
            success: function (result) {
                var _result = eval('(' + result + ')');//eval()解析单个json对象

                if (_result&&_result.content) {
                    $("#notice").html(_result.content);
                }
                
            }
        });
    }

//自留回库 12-15
function BackDia_Js(me,gwRate) {
    $(".BackDia_box").show();

    $(".pop .colse_popbox").click(function () {
        $(".BackDia_box").hide();
    });

    $.ajax({
        url: "/Team/GetOrderInfo",//提交地址
        type: "POST",//提交方式
        data: "{'OrderID':'" + me.getAttribute("value") + "'}",
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var _result = eval('(' + result + ')');//eval()解析单个json对象

            $("#_orID").val(_result.OrderID);//12-16
            $("#_invID").val(_result.InventoryID);
            $("#originSN").val(_result.OriginSN);
            $("#shape").val(_result.Shape);
            $("#weight").val(_result.Weight);
            $("#color").val(_result.Color);//白钻颜色/彩钻颜色
            $("#clarity").val(_result.Clarity);
            $("#cut").val(_result.Cut);
            $("#polish").val(_result.Polish);
            $("#symmetry").val(_result.Symmetry);
            $("#fluorescence").val(_result.Fluorescence);
            $("#certType").val(_result.CertType);
            $("#certNo").val(_result.CertNo);
           
            $("#milky").val(_result.Milky);
            $("#hue").val(_result.Hue);
            $("#hA").val(_result.HA);
            $("#blackDefect").val(_result.BlackDefect);
            $("#otherDefect").val(_result.OtherDefect);
            $("#place").val(_result.Place); 
            $("#status").val(_result.Status);
            $("#comments").val(_result.Comments);
            $("#_rapnet").val(_result.Rapnet);
            $("#_isFancy").val(_result.IsFancy);
            //原采购部分 01-12
            $("#back_purchaseExchange").val(_result.PurchaseExchangerate);//01-12
            $("#back_purchaseSupplier").val(_result.SupplierCode);//01-12
            $("#sourceDiscountReturn").val(_result.DiscountReturn);//原退点 
            $("#sourceDolarPerGrain").val(_result.PriceUSD);//原美金
            $("#sourceRmbGrain").val((_result.ConfirmPrice / (100 + _result.Confirmdiscount) * (100 + _result.DiscountReturn)).toFixed(3));//01-12  sourceRmbGrain
            
            //买
            $("#back_purchaseUSDPerGrain").val(_result.PriceUSD);//01-12 买美金
            $("#back_purchaseUSDPerGrain").attr("lang", (_result.ConfirmUSD / _result.Weight).toFixed(3));//01-12  carat/usd
            $("#back_purchaseDiscountReturn").val(_result.DiscountReturn);//01-12 买退点
             
            $("#back_purchaseRmbPerGrain").val((_result.ConfirmPrice / (100 + _result.Confirmdiscount) * (100 + _result.DiscountReturn)).toFixed(3));//01-12买RMB
            $("#SaleseRate").val(_result.SalesExchangerate);//01-12


            //addGlobalWhiteRateCalcPriceAndDisc(parseFloat(gwRate));  // 加上全局退点后的原退点、美金总价、人民币总价
        }
    });
}

//申请RMB余额（订单和客户管理 12-10）
function ApplyFlow_Js(me) {
    $(".Balance_box").show();
    $(".pop .colse_popbox").click(function () {
        $(".Balance_box").hide();
    });

    $.ajax({
        url: "/Customer/GetCustomerInfo",//提交地址
        type: "POST",//提交方式
        data: "{'CustomerID':'" + me.getAttribute("value") + "'}",
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var _result = eval('(' + result + ')');//eval()解析单个json对象              

            //客户申请余额
            $("#_custID").val(_result.CustomerID);
            $("#_realName").val(_result.RealName);
            $("#_realNa").val(_result.RealName);
            $("#_bal").val(_result.Balance);

        }
    });

    CzAccountLoad();//账户列表 12-21
}


//申请USD余额（订单和客户管理 01-18）
function ApplyUSDFlow_Js(me) {
    $(".USDBalance_box").show();
    $(".pop .colse_popbox").click(function () {
        $(".USDBalance_box").hide();
    });

    CzUSDAccountLoad();//账户列表 12-21

    $.ajax({
        url: "/Customer/GetCustomerInfo",//提交地址
        type: "POST",//提交方式
        data: "{'CustomerID':'" + me.getAttribute("value") + "'}",
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var _result = eval('(' + result + ')');//eval()解析单个json对象              

            //客户申请余额
            $("#_cuID").val(_result.CustomerID);
            $("#_cID").val(_result.CustomerID);
            $("#_reName").val(_result.RealName);
            $("#_usdbal").val(_result.USDBalance);

        }
    });
}

//申请Cz美金充值账户列表 12-21
function CzUSDAccountLoad() {

    var requestAccount = {};

    requestAccount.Status = 1;//启用1
    requestAccount.Type = '2,3';//01-11 只要传了Type就不显示Type=2和3的账户 01-11
    requestAccount.Currency = 2;//01-11 人民币1 美金2

    $.ajax({
        url: "/Team/GetBankList",//提交地址
        type: "POST",//提交方式
        async: false, //异步 9-27
        data: JSON.stringify(requestAccount),
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var _result = eval('(' + result + ')');//eval()解析单个json对象

            if (_result.msgcode == false) {
                var options = "";
                options += '<lable>' + _result.msginfo + '</label>';
                $("#_usdbankID").html("");//账户下拉
                $("#_usdbankID").html(options);
            } else {
                var options = "";
                for (var i = 0; i < _result.length; i++) {
                    options += '<div><input type="radio" name="Account" value="' + _result[i].BankID + '" id="czaccout' + i + '" /><label for="czaccout' + i + '">' + _result[i].BankName + '</label></div>';
                }
                $("#_usdbankID").html("");//账户下拉
                $("#_usdbankID").html(options);
            }
        }
    });
}

//客户充值框(订单管理和客户管理)
function ReCharge_Js(me) {
    $(".ReCharge_box").show();
    $(".pop .colse_popbox").click(function () {
        $(".ReCharge_box").hide();
    });

    $.ajax({
        url: "/Customer/GetCustomerInfo",//提交地址
        type: "POST",//提交方式
        data: "{'CustomerID':'" + me.getAttribute("value") + "'}",
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var _result = eval('(' + result + ')');//eval()解析单个json对象              

            //客户充值
            $("#_customerid").val(_result.CustomerID);
            $("#RealName").val(_result.RealName);
            $("#Balance").val(_result.Balance);

        }
    });
}

//供应商联系方式  11-5
function Contact_Js(me) {
    $(".pop .colse_popbox").click(function () {
        $(".Contact_box").hide();
    });

    $.ajax({
        url: "/Team/ContactSupplier",//提交地址
        type: "POST",//提交方式
        data: "{'SupplierCode':'" + me.getAttribute("value") + "'}",
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var _result = eval('(' + result + ')');//eval()解析单个json对象
            if (_result.msgcode == false) {
                alert(_result.msginfo);
            } else {

                $(".Contact_box").show();

                var _result = eval('(' + _result + ')');//再次解析_result

                if (_result.result == true) {
                    $("#_company").val(_result.Company);
                    $("#_shortName").val(_result.ShortName);
                    $("#_website").val(_result.Contact.Website);//json.json.json
                    $("#_qq").val(_result.Contact.QQ);
                    $("#_name").val(_result.Contact.Name); //Telephone 
                    $("#_telephone").val(_result.Contact.Telephone);
                    $("#_rapid").val(_result.Contact.RapID);
                    //$("#_skype").val(_result.Contact.Skype);
                    if (_result.Contact.Skype != "") {
                        $("#_skype").html("<b style='font-size:20px;' title='点击和" + _result.Contact.Skype + "聊天'><span><img src='https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1489148014986&di=253cba520b4b4c293c60f95cabd708db&imgtype=0&src=http%3A%2F%2Fimg.download.pchome.net%2F3p%2F7b%2Flogo.jpg' style='border: none;width:20px;height:20px;' /></span><label>" + _result.Contact.Skype + "</label></b>");//点击打开Skype
                    } else {
                        $("#_skype").html("");
                    }
                    $("#_email").val(_result.Contact.Email);
                    $("#_wechat").val(_result.Contact.WeChat);
                    $("#_mobilephone").val(_result.Contact.MobilePhone);                   
                    $("#_address").val(_result.Address.Country + "-" + _result.Address.State + "-" + _result.Address.City);//中国-广东-深圳
                } else {
                    //暂无联系方式
                    toast("供应商暂无联系方式");
                    $(".Contact_box").hide();
                }               
            }

        }
    });
}       

//屏蔽供应商  11-28
function Filter_Js(me) {
    $(".Filter_box").show();

    //确认屏蔽裸钻供应商
    $("#_filterStocks").click(function () {

        $.ajax({
            url: "/Team/SetSupplier",//提交地址
            type: "POST",//提交方式
            data: "{'supplierCode':'" + me.getAttribute("value") + "','category':'stocks','state':'true'}", //{"supplierCode":"YDT","category":"stocks","state":false}
            contentType: "application/json; charset=utf-8",
            success: function (result) {
                var _result = eval('(' + result + ')');//eval()解析单个json对象

                if (_result.result == true) {
                    alert(_result.result);
                    $(".Filter_box").hide();
                }else{
                    alert(_result.result);
                }               

            }
        });
    });

    //确认屏蔽统包供应商
    $("#_filterParcels").click(function () {

        $.ajax({
            url: "/Team/SetSupplier",//提交地址
            type: "POST",//提交方式
            data: "{'supplierCode':'" + me.getAttribute("value") + "','category':'parcels','state':'true'}", //{"supplierCode":"YDT","category":"stocks","state":false}
            contentType: "application/json; charset=utf-8",
            success: function (result) {
                var _result = eval('(' + result + ')');//eval()解析单个json对象

                if (_result.result == true) {
                    alert(_result.result);
                    $(".Filter_box").hide();
                } else {
                    alert(_result.result);
                }

            }
        });
    });

    //确认屏蔽成品供应商
    $("#_filterInlays").click(function () {

        $.ajax({
            url: "/Team/SetSupplier",//提交地址
            type: "POST",//提交方式
            data: "{'supplierCode':'" + me.getAttribute("value") + "','category':'inlays','state':'true'}", //{"supplierCode":"YDT","category":"stocks","state":false}
            contentType: "application/json; charset=utf-8",
            success: function (result) {
                var _result = eval('(' + result + ')');//eval()解析单个json对象

                if (_result.result == true) {
                    alert(_result.result);
                    $(".Filter_box").hide();
                } else {
                    alert(_result.result);
                }

            }
        });
    });    

    $(".pop .colse_popbox").click(function () {
        $(".Filter_box").hide();
    });
}


function cart_in() {
    $(".cart_icon_in").hide();
    $(".cart_icon_out").show();
}
function cart_out() {
    $(".cart_icon_out").hide();
    $(".cart_icon_in").show();
}

//格式成货币格式 12-19
function FormatMoney(number, places, symbol, thousand, decimal) {
    if (number != null) {
        number = number || 0;
        places = !isNaN(places = Math.abs(places)) ? places : 2;
        symbol = symbol !== undefined ? symbol : "";//$
        thousand = thousand || ",";
        decimal = decimal || ".";
        var negative = number < 0 ? "-" : "",
            i = parseInt(number = Math.abs(+number || 0).toFixed(places), 10) + "",
            j = (j = i.length) > 3 ? j % 3 : 0;
        return symbol + negative + (j ? i.substr(0, j) + thousand : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousand) + (places ? decimal + Math.abs(number - i).toFixed(places).slice(2) : "");
    } else {
        return "-";
    }
    return number;
}

//形状格式化(公共JS方法)
function ShapeFormat(shapeValue) {
    var dic = ["其他", "圆形", "公主方", "祖母绿", "雷迪恩", "椭圆形", "梨形", "马眼形", "心形", "三角形", "垫形", "其他"]
    if (dic.length >= shapeValue && shapeValue > 0) {
        return dic[shapeValue];
    }
    return dic[0];
}
//订单状态格式化(团队)
function UserOrderStatusFormat(orderStatusValue) {
    if (orderStatusValue == 1) {
        return "待采购";
    } else if (orderStatusValue == 2) {
        return "待到货";
    } else if (orderStatusValue == 3) {
        return "待出货";
    } else if (orderStatusValue == 4) {
        return "已出货";
    } else if (orderStatusValue == 5) {
        return "已作废";
    } else if (orderStatusValue == 6) {
        return "已自留";
    } else if (orderStatusValue == 7) {
        return "已退回";
    }
    return orderStatusValue;
}


//成品订单状态格式化(团队)
function RingOrderStatusFormat(orderStatusValue) {
    if (orderStatusValue == 3) {
        return "待出货";
    } else if (orderStatusValue ==4) {
        return "已到货";
    } else if (orderStatusValue == 5) {
        return "已作废";
    } else if (orderStatusValue == 7) {
        return "已退货";
    }
    return orderStatusValue;
}

//成品订单状态格式化(客户)
function CustomerRingOrderStatusFormat(orderStatusValue) {
    if (orderStatusValue == 3) {
        return "下单成功";
    } else if (orderStatusValue == 4) {
        return "出货成功";
    } else if (orderStatusValue == 5) {
        return "作废成功";
    } else if (orderStatusValue == 7) {
        return "退货成功";
    }
    return orderStatusValue;
}

//订单状态格式化(客户)
function CustomerOrderStatusFormat(orderStatusValue) {
    if (orderStatusValue == 1) {
        return "下单成功";
    } else if (orderStatusValue == 2) {
        return "定购成功";
    } else if (orderStatusValue == 3) {
        return "到货成功";
    } else if (orderStatusValue == 4) {
        return "交货成功";
    } else if (orderStatusValue == 5) {
        return "作废成功";
    } else if (orderStatusValue == 6) {
        return "退货成功";
    } else if (orderStatusValue == 7) {
        return "退货成功";
    }
    return orderStatusValue;
}

//收款状态格式化
function PaymentStatusFormat(paymentStatusValue) {
    if (paymentStatusValue != null) {
        if (paymentStatusValue == 1) {
            return "<b style='color:red;'>已收</b>";
        } else if (paymentStatusValue == 0) {
            return "未收";
        } else {
            return paymentStatusValue;
        }
    } else {
        return "-";
    }
}

//付款状态格式化
function ReceiptStatusFormat(receiptStatusValue) {
    if (receiptStatusValue != null) {
        if (receiptStatusValue == 1) {
            return "<b style='color:red;'>已付</b>";
        } else if (receiptStatusValue == 0) {
            return "未付";
        } else if (receiptStatusValue == 2) {
            return "<b style='color:green;'>未清</b>";
        } else {
            return receiptStatusValue;
        }
    } else {
        return "-";
    }
}

//Null格式化为空白
function NullFormat(nullValue) {
    if (nullValue == null) {
        return "-";
    }
    return nullValue;
}
function Nullmat(value) {
    if (value == null) {
        return 0;
    }
    return parseInt(value);
}
//币种Currency格式化
function CurrencyFormat(currValue) {
    if (currValue == 1) {
        return "人民币";
    } else if (currValue == 2) {
        return "美元";
    } else if (currValue == null) {
        return "-";
    } else {
        return currValue;
    }
}

//客户状态格式化
function CustomerSysStatusFormat(sysStatusValue) {
    var dic = ["禁用", "正常", "待审", "待出货", "待结款", "已结束"] //（-1 已删除 0 已禁用 2 审核中 1正常）
    if (dic.length >= sysStatusValue && sysStatusValue > 0) {
        return dic[sysStatusValue];
    }
    return dic[0];
}

    //角色格式化
    function RoleIDFormat(roleIDValue) {
        if (roleIDValue == 1) {
            return "管理员";
        } else if (roleIDValue == 2) {
            return "会计员";
        } else if (roleIDValue == 3) {
            return "业务员";
        } else if (roleIDValue == 4) {
            return "采购员";
        } else if (roleIDValue == 5) {
            return "物流员";
        } else if (roleIDValue == 6) {
            return "副管";
        }else if(roleIDValue==7){
            return "业务经理";
        }else if(roleIDValue==8){
            return "顾问";
        } else if (roleIDValue == null) {
            return "";
        }
        return roleIDValue;
    }

    //货品状态格式化
    function StatusFormat(statusValue) {
        if (statusValue == 0) {
            return "待查";
        }else if (statusValue == 1) {
            return "在库";
        } else if (statusValue == 2) {
            return "借出";
        } else if (statusValue == 3) {
            return "实验室";
        } else if (statusValue == 4) {
            return "保留";
        } else if (statusValue == 5) {
            return "展会";
        } else if (statusValue == null) {
            return "";
        }
        return statusValue;
    }

    //上下架格式化
    function OnShelvesFormat(shelvesValue) {
        if (shelvesValue == 1) {
            return "上架中";
        } else if (shelvesValue == 0) {
            return "<b style='color:red;'>下架中</b>";
        } else {
            return shelvesValue;
        }
    }

    //奶油格式化
    function MilkyFormat(milkyValue) {
        if (milkyValue) {
            var milky = milkyValue.toLowerCase();//不区分大小写
            if (milky == "ml4") {
                return "重奶";
            } else if (milky == "ml3") {
                return "中奶";
            } else if (milky == "ml2") {
                return "轻奶";
            } else if (milky == "ml1") {
                return "很轻奶";
            } else if (milky == "ml0") {
                return "无奶";
            } else if (milky == "ml") {
                return "带奶";
            } else if (milky == "na") {
                return "待查";
            } else{ 
                return milkyValue;
            }
        } else {
            //Null
            return "";//null
        }        
        return milkyValue;
    }

    //色调格式化
    function HueFormat(hueValue) {
        var huechn = "";
        if (hueValue) {
            var hue = hueValue.toLowerCase();//不区分大小写

            //咖br
            if (hue.indexOf("br") > -1) {
                if (hue.indexOf("br0") > -1) {
                    huechn += "无咖 ";
                } else if (hue.indexOf("br1") > -1) {
                    huechn += "轻微咖 ";
                } else if (hue.indexOf("br2") > -1) {
                    huechn += "轻咖 ";
                } else if (hue.indexOf("br3") > -1) {
                    huechn += "中咖 ";
                } else if (hue.indexOf("br4") > -1) {
                    huechn += "大咖 ";
                } else if (hue.indexOf("br5") > -1) {
                    huechn += "很大咖 ";
                } else if (hue.indexOf("br") > -1) {
                    huechn += "有咖 ";
                }
            }
            //绿gr
            if (hue.indexOf("gr") > -1) {
                if (hue.indexOf("gr0") > -1) {
                    huechn += "无绿 ";
                } else if (hue.indexOf("gr1") > -1) {
                    huechn += "轻微绿 ";
                } else if (hue.indexOf("gr2") > -1) {
                    huechn += "轻绿 ";
                } else if (hue.indexOf("gr3") > -1) {
                    huechn += "中绿 ";
                } else if (hue.indexOf("gr4") > -1) {
                    huechn += "大绿 ";
                } else if (hue.indexOf("gr5") > -1) {
                    huechn += "很大绿 ";
                } else if (hue.indexOf("gr") > -1) {
                    huechn += "有绿 ";
                }
            }
            if (hue.indexOf("mix") > -1) {
                huechn += "混色 ";
            }
            if (hue.indexOf("pk") > -1) {              
                    huechn += "粉色 ";                
            }
            if (hue.indexOf("re") > -1) {
                huechn += "红色 ";
            }
            if (hue.indexOf("ye") > -1) {
                huechn += "黄色 ";
            }
            if (hue.indexOf("ow") > -1) {
                huechn += "灰白 ";
            }
            if (hue.indexOf("gy") > -1) {
                huechn += "灰色 ";
            }
            if (hue.indexOf("bl") > -1) {
                huechn += "蓝色 ";
            }
            if (hue.indexOf("or") > -1) {
                huechn += "橙色 ";
            }
            if (hue.indexOf("fy") > -1) {
                huechn += "彩色 ";
            }
            //包含na
            if (hue.indexOf("na") > -1) {
                huechn += "待查 ";
            }

            if (huechn != "") {
                return huechn;
            } else {
                return hueValue;
            }

        } else {
            return "待查 ";//null
        }
        return hueValue;
    }    

        //心箭格式化
        function HAFormat(haValue) {
            if(haValue){
                var ha = haValue.toLowerCase();//不区分大小写

                if (ha == "id") {
                    return "理想";
                }else if(ha=="ex"){
                    return "极好";
                } else if (ha == "vg") {
                    return "很好";
                } else if (ha == "gd") {
                    return "较好";
                } else if (ha == "fr") {
                    return "一般";
                } else if (ha == "pr") {
                    return "较差";
                } else if (ha == "y") {
                    return "有";
                } else if (ha == "n") {
                    return "无";
                } else if (ha == "na") {
                    return "待查";
                } else if (ha == "") {
                    return "待查";
                } else {
                    return haValue;
                }
            }else{
                return "待查";//null
            }
            return haValue;
        }

        //黑点格式化 TSB TB  SB  BK
        function BlackDefectFormat(blackDefectValue) {
            var blackchn = "";

            if (blackDefectValue) {
                var black = blackDefectValue.toLowerCase();//不区分大小写

                //包含na
                if (black.indexOf("na") > -1) {
                    blackchn += "待查 ";
                }

                //包含tsb
                if (black.indexOf("ts") > -1) {
                    if (black.indexOf("tsb0") > -1) {
                        blackchn += "台冠无黑 ";
                    } else if (black.indexOf("tsb1") > -1) {
                        blackchn += "台冠轻微黑 ";
                    } else if (black.indexOf("tsb2") > -1) {
                        blackchn += "台冠轻黑 ";
                    } else if (black.indexOf("tsb3") > -1) {
                        blackchn += "台冠中黑 ";
                    } else if (black.indexOf("tsb4") > -1) {
                        blackchn += "台冠大黑 ";
                    } else if (black.indexOf("tsb") > -1) {
                        blackchn += "台冠有黑 ";
                    }
                }
                //包含tb
                if (black.indexOf("tb") > -1) {
                    if (black.indexOf("tb0") > -1) {
                        blackchn += "台无黑 ";
                    } else if (black.indexOf("tb1") > -1) {
                        blackchn += "台轻微黑 ";
                    } else if (black.indexOf("tb2") > -1) {
                        blackchn += "台轻黑 ";
                    } else if (black.indexOf("tb3") > -1) {
                        blackchn += "台中黑 ";
                    } else if (black.indexOf("tb4") > -1) {
                        blackchn += "台大黑 ";
                    } else if (black.indexOf("tb") > -1) {
                        blackchn += "台有黑 ";
                    }
                }

                //包含sb
                if (black.indexOf("sb") > -1) {
                    if (black.indexOf("sb0") > -1) {
                        blackchn += "冠无黑 ";
                    } else if (black.indexOf("sb1") > -1) {
                        blackchn += "冠轻微黑 ";
                    } else if (black.indexOf("sb2") > -1) {
                        blackchn += "冠轻黑 ";
                    } else if (black.indexOf("sb3") > -1) {
                        blackchn += "冠中黑 ";
                    } else if (black.indexOf("sb4") > -1) {
                        blackchn += "冠大黑 ";
                    } else if (black.indexOf("sb") > -1) {
                        blackchn += "冠有黑 ";
                    }
                }

                //包含bk
                if (black.indexOf("bk") > -1) {
                    if (black.indexOf("bk0") > -1) {
                        blackchn += "无黑 ";
                    } else if (black.indexOf("bk1") > -1) {
                        blackchn += "轻微黑 ";
                    } else if (black.indexOf("bk2") > -1) {
                        blackchn += "轻黑 ";
                    } else if (black.indexOf("bk3") > -1) {
                        blackchn += "中黑 ";
                    } else if (black.indexOf("bk4") > -1) {
                        blackchn += "大黑 ";
                    } else if (black.indexOf("bk") > -1) {
                        blackchn += "有黑 ";
                    }
                }

                if (blackchn != "") {
                    return blackchn;
                } else {
                    return blackDefectValue;//11-23
                }

            } else {
                return "待查 ";//null
            }
            return blackDefectValue;//11-23
        }        

        //瑕疵格式化 TSI TI SI TSO TO SO OI I
        function OtherDefectFormat(otherDefectValue) {
            var defectchn = "";

            if (otherDefectValue) {
                var defect = otherDefectValue.toLowerCase();//不区分大小写

                //包含na
                if (defect.indexOf("na") > -1) {
                    defectchn += "待查 ";
                }

                //里面
                //包含tsi
                if (defect.indexOf("tsi") > -1) {
                    if (defect.indexOf("tsi0") > -1) {
                        defectchn += "台冠无瑕 ";
                    } else if (defect.indexOf("tsi1") > -1) {
                        defectchn += "台冠轻微瑕 ";
                    } else if (defect.indexOf("tsi2") > -1) {
                        defectchn += "台冠轻瑕 ";
                    } else if (defect.indexOf("tsi3") > -1) {
                        defectchn += "台冠中瑕 ";
                    } else if (defect.indexOf("tsi4") > -1) {
                        defectchn += "台冠大瑕 ";
                    } else if (defect.indexOf("tsi") > -1) {
                        defectchn += "台冠有瑕 ";
                    } 
                }
                //包含ti
                if (defect.indexOf("ti") > -1) {
                    if (defect.indexOf("ti0") > -1) {
                        defectchn += "台无瑕 ";
                    } else if (defect.indexOf("ti1") > -1) {
                        defectchn += "台轻微瑕 ";
                    } else if (defect.indexOf("ti2") > -1) {
                        defectchn += "台轻瑕 ";
                    } else if (defect.indexOf("ti3") > -1) {
                        defectchn += "台中瑕 ";
                    } else if (defect.indexOf("ti4") > -1) {
                        defectchn += "台大瑕 ";
                    } else if (defect.indexOf("ti") > -1) {
                        defectchn += "台有瑕 ";
                    } 
                }
                //包含si
                if (defect.indexOf("si") > -1) {
                    if (defect.indexOf("si0") > -1) {
                        defectchn += "冠无瑕 ";
                    } else if (defect.indexOf("si1") > -1) {
                        defectchn += "冠轻微瑕 ";
                    } else if (defect.indexOf("si2") > -1) {
                        defectchn += "冠轻瑕 ";
                    } else if (defect.indexOf("si3") > -1) {
                        defectchn += "冠中瑕 ";
                    } else if (defect.indexOf("si4") > -1) {
                        defectchn += "冠大瑕 ";
                    } else if (defect.indexOf("si") > -1) {
                        defectchn += "冠有瑕 ";
                    } 
                }              

                //表面

                //包含tso
                if (defect.indexOf("tso") > -1) {
                    if (defect.indexOf("tso0") > -1) {
                        defectchn += "台表无瑕 ";
                    } else if (defect.indexOf("tso1") > -1) {
                        defectchn += "台表轻微瑕 ";
                    } else if (defect.indexOf("tso2") > -1) {
                        defectchn += "台表轻瑕 ";
                    } else if (defect.indexOf("tso3") > -1) {
                        defectchn += "台表中瑕 ";
                    } else if (defect.indexOf("tso4") > -1) {
                        defectchn += "台表大瑕 ";
                    } else if (defect.indexOf("tso") > -1) {
                        defectchn += "台表有瑕 ";
                    } 
                }

                //包含to
                if (defect.indexOf("to") > -1) {
                    if (defect.indexOf("to0") > -1) {
                        defectchn += "台表无瑕 ";
                    } else if (defect.indexOf("to1") > -1) {
                        defectchn += "台表轻微瑕 ";
                    } else if (defect.indexOf("to2") > -1) {
                        defectchn += "台表轻瑕 ";
                    } else if (defect.indexOf("to3") > -1) {
                        defectchn += "台表中瑕 ";
                    } else if (defect.indexOf("to4") > -1) {
                        defectchn += "台表大瑕 ";
                    } else if (defect.indexOf("to") > -1) {
                        defectchn += "台表有瑕 ";
                    } 
                }

                //包含so
                if (defect.indexOf("so") > -1) {
                    if (defect.indexOf("so0") > -1) {
                        defectchn += "冠表无瑕 ";
                    } else if (defect.indexOf("so1") > -1) {
                        defectchn += "冠表轻微瑕 ";
                    } else if (defect.indexOf("so2") > -1) {
                        defectchn += "冠表轻瑕 ";
                    } else if (defect.indexOf("so3") > -1) {
                        defectchn += "冠表中瑕 ";
                    } else if (defect.indexOf("so4") > -1) {
                        defectchn += "冠表大瑕 ";
                    } else if (defect.indexOf("so") > -1) {
                        defectchn += "冠表有瑕 ";
                    }
                }

                //包含oi
                if (defect.indexOf("oi") > -1) {
                    if (defect.indexOf("oi0") > -1) {
                        defectchn += "表无瑕 ";
                    } else if (defect.indexOf("oi1") > -1) {
                        defectchn += "表轻微瑕 ";
                    } else if (defect.indexOf("oi2") > -1) {
                        defectchn += "表轻瑕 ";
                    } else if (defect.indexOf("oi3") > -1) {
                        defectchn += "表中瑕 ";
                    } else if (defect.indexOf("oi4") > -1) {
                        defectchn += "表大瑕 ";
                    } else if (defect.indexOf("oi") > -1) {
                        defectchn += "表有瑕 ";
                    }
                }

                //等于I
                if (defect == "i") {
                    defectchn = "有瑕";
                } else if (defect == "i0") {
                    defectchn = "无瑕";
                } else if (defect == "i1") {
                    defectchn = "微瑕";
                } else if (defect == "i2") {
                    defectchn = "小瑕";
                } else if (defect == "i3") {
                    defectchn = "中瑕";
                } else if (defect == "i4") {
                    defectchn = "大瑕";
                }

                if (defectchn != "") {
                    return defectchn;
                } else {
                    return otherDefectValue;
                }
            } else {
                //空
                return "待查 ";//null
            }
            return otherDefectValue;
        }        


//肉眼干净格式化
        function EyeCleanFormat(eyeCleanValue) {
            if (eyeCleanValue == "EC0") {
                return "100%";
            } else if (eyeCleanValue == "EC1") {
                return "80%";
            } else if (eyeCleanValue == "EC2") {
                return "60%";
            } else if (eyeCleanValue == "EC3") {
                return "不干净";
            } else if (eyeCleanValue == "NA") {
                return "待查";
            } else if (eyeCleanValue == null) {
                return "";
            } else {
                return eyeCleanValue;
            }
        }

    //所在地格式化
    function PlaceFormat(place) {
        if (place =="HK") {
            return "香港";
        } else if (place=="IND") {
            return "印度";
        } else if (place == "CHN") {
            return "国内";
        }else if (place == "UAE") {
            return "阿联酋";
        }else if (place == "BEL") {
            return "比利时";
        } else if (place == "UN") {
            return "英国";
        } else if (place == "ISR") {
            return "以色列";
        } else if (place == "USA") {
            return "美国";
        } else if (place == "JPN") {
            return "日本";
        } else if (place == "TL") {
            return "泰国";
        } else if (place == "SZ") {
            return "深圳";
        } else if (place == "SH") {
            return "上海";
        } else if (place == "BJ") {
            return "北京";
        } else if (place == "GZ") {
            return "广州";
        } else if (place == "UK") {
            return "英国";
        } else if (place == "GIA") {
            return "实验室";
        }else {
            return place;
        }
    }


    //货品状态
    function GoodsStatusFormat(goodsStatusValue) {
        if (goodsStatusValue == 1) {
            return "在库";
        } else if (goodsStatusValue == 2) {
            return "借出";
        } else if (goodsStatusValue == 3) {
            return "实验室";
        } else if (goodsStatusValue == 4) {
            return "预留";
        } else if (goodsStatusValue == 5) {
            return "展会";
        } else if (goodsStatusValue ==null) {
            return "";
        } else {
            return "待查";
        }
        return goodsStatusValue;
    }

//订单类型 9-10
    function OrderTypeFormat(orderTypeValue) {
        if (orderTypeValue == 1) {
            return "客下";
        } else if (orderTypeValue == 2) {
            return "代下";
        } else if (orderTypeValue == 3) {
            return "录单";
        } else if (orderTypeValue == 4) {
            return "二级"; //二级订单
        }
        return orderTypeValue;
    }

//是否彩钻
    function IsFancyFormat(isFancyValue) {
        if (isFancyValue == 1) {
            return "彩钻";
        } else if (isFancyValue == 0) {
            return "白钻";
        }
        return isFancyValue;
    }

//是否到货 9-10
    function ArrivalFormat(arrivalValue) {
        if (arrivalValue == 0) {
            return "否";
        } else if (arrivalValue ==1) {
            return "是";
        }
        return arrivalValue;
    }


    //是否换货 9-10
    function ReplacementFormat(reploacementValue) {
        if (reploacementValue == 0) {
            return "否";
        } else if (reploacementValue == 1) {
            return "是";
        }
        return reploacementValue;
    }

    //证书号格式化
    function CertNoFormat(certNoValue) {
        if (certNoValue ==null) {
            return "";
        }
        return certNoValue;
    }

    //货号格式化
    function SNFormat(sNValue) {
        if (sNValue == null) {
            return "";
        }
        return sNValue;
    }

    //国际报价格式化
    function RapnetFormat(rapnetValue) {
        if (rapnetValue == null || rapnetValue== 0) {
            return "-";
        }
        return rapnetValue;
    }

    //客户卖出折扣格式化 
    function CustomerDiscountReturnFormat(customerDiscountValue) {
        if (customerDiscountValue == null) {
            return "-";
        }
        return customerDiscountValue;
    }

     //购物车来源
    function CartType(cartValue) {
        if (cartValue == 1) {
            return "电脑端";
        }else if (cartValue == 2) {
            return "苹果端";
        } else if (cartValue == 3) {
            return "安卓端";
        }
    }

//成品格式化start

    //风格Style 1-7
    function StyleFormat(styleValue) {
        if (styleValue == 1) {
            return "豪华";
        } else if (styleValue == 2) {
            return "经典";
        } else if (styleValue == 3) {
            return "简约";
        } else if (styleValue == 4) {
            return "阳光";
        } else if (styleValue == 5) {
            return "行意";
        } else if (styleValue == 6) {
            return "中性";
        } else if (styleValue == 7) {
            return "花俏";
        } else {
            return styleValue;
        }
    }

    //材质Quality
    function QualityFormat(qualityValue) {
        if (qualityValue == 1) {
            return "18K";
        } else if (qualityValue == 2) {
            return "14K";
        } else if (qualityValue == 3) {
            return "PY950";
        } else if (qualityValue == 4) {
            return "PT900";
        } else if (qualityValue == 5) {
            return "10k";
        } else if (qualityValue == 6) {
            return "钯金";
        } else if (qualityValue == 7) {
            return "&lt;10K";
        } else if (qualityValue == 8) {
            return "其他";
        } else {
            return qualityValue;
        }
    }   
    
    //统包类型
    function ParcelCategoryFormat(categoryValue) {
        if (categoryValue == 1) {
            return "白钻";
        } else if (categoryValue == 2) {
            return "彩钻";
        } else {
            return categoryValue;
        }
    }

    
     //主石类型（成品）MainType
    function RMainTypeFormat(mainTypeValue) {
        if (mainTypeValue == 1) {
            return "空托";
        } else if (mainTypeValue == 2) {
            return "白钻";
        } else if (mainTypeValue == 3) {
            return "彩钻";
        } else if (mainTypeValue == 4) {
            return "红宝";
        } else if (mainTypeValue == 5) {
            return "蓝宝";
        } else if (mainTypeValue == 6) {
            return "祖母绿";
        } else if (mainTypeValue == 7) {
            return "坦桑";
        } else if (mainTypeValue == 8) {
            return "碧玺";
        } else {
            return mainTypeValue;
        }
    }

     //主石类型（彩宝）
    function GMainTypeFormat(mainTypeValue) {
        if (mainTypeValue == 1) {
            return "红宝";
        } else if (mainTypeValue == 2) {
            return "蓝宝";
        } else if (mainTypeValue == 3) {
            return "祖母绿";
        } else if (mainTypeValue == 4) {
            return "坦桑";
        } else if (mainTypeValue == 5) {
            return "碧玺";
        } else {
            return mainTypeValue;
        }
    }

    //是否现货IsStock
    function IsStockFormat(isStockValue) {
        if (isStockValue == 1) {
            return "现货";
        } else if (isStockValue == 2) {
            return "定制";
        } else {
            return isStockValue;
        }
    }

    //成品状态
    function InlaysStatusFormat(statusValue) {
        if (statusValue == 1) {
            return "在库";
        } else if (statusValue == 2) {
            return "借出";
        } else {
            return statusValue;
        }
    }

    //成品主石颜色MainColor(新增主石颜色)
    function MainColorFormat(mainColorValue) {
        if (mainColorValue == "<N") {
            return "小于N";
        } else if (mainColorValue == "PARAIBA") {
            return "帕拉伊巴";
        } else if (mainColorValue == "WATERMELON") {
            return "西瓜";
        } else if (mainColorValue == "RUPIAH") {
            return "卢比来";
        } else if (mainColorValue == "RED") {
            return "红色";
         } else if (mainColorValue == "BLUE") {
            return "蓝色";
        } else if (mainColorValue == "GREEN") {
            return "绿色";
        } else if (mainColorValue == "MUZO") {
            return "木佐";
        } else if (mainColorValue == "LAVENDER") {
            return "薰衣草";
        } else if (mainColorValue == "ROYALBLUE") {
            return "皇家兰";
        } else if (mainColorValue == "COLORBLUE") {
            return "彩色蓝宝";
        } else if (mainColorValue == "VIVID RED") {
            return "鸽血红";
        } else if (mainColorValue == "YELLOW") {
            return "黄色";
        } else if (mainColorValue == "PINK") {
            return "粉色";
        } else if (mainColorValue == "BLACK") {
            return "黑色";
        } else if (mainColorValue == "BROWN") {
            return "啡色";
        } else if (mainColorValue == "ORANGE") {
            return "香槟";
        } else if (mainColorValue == "OTHER") {
            return "其它";
        } else {
            return mainColorValue;
        }
    }

    //成品主石净度MainClarity
    function MainClarityFormat(mainClarityValue) {
        if (mainClarityValue == "<P") {
            return "小于P";
        } else {
            return mainClarityValue;
        }
    }

//成品格式化end


//统包格式化start

    //统包颜色Color
    function ParcelsColorFormat(colorValue) {
        if (colorValue == "<N") {
            return "小于N";
        } else {
            return colorValue;
        }
    }


//统包格式化end

    //截取字符串前10个
    function StringFormat(stringValue) {
        if (stringValue == null) {
            return "";
        }
        return stringValue;
    }

    //卖出退点格式化
    function ConfirmdiscountFormat(confirmDiscountValue) {
        if (confirmDiscountValue == null) {
            return "";
        }
        return confirmDiscountValue;
    }

    //原退点格式化
    function DiscountFormat(discountValue) {
        if (discountValue == null) {
            return "";
        }
        return discountValue;
    }

    //卖出人民币总价格式化
    function ConfirmPriceFormat(confirmPriceValue){
        if (confirmPriceValue == null) {
            return "";
        }
        return confirmPriceValue;
    }

    //买入人民币总价格式化
    function PurchasedRMBFormat(purchasedRMBValue) {
        if (purchasedRMBValue == null) {
            return "";
        }
        return purchasedRMBValue;
    }

    //买入美金格式化
    function PriceUSDFormat(priceUSDValue) {
        if (priceUSDValue == null) {
            return "";
        }
        return priceUSDValue;
    }

    //带链接的证书类型
    function CertTypeFormat(row) {
        row.CertType = row.CertType ? row.CertType.toUpperCase() : "";
        //http://api.checkgems.com/static/pdfjs/web/viewer.html?file=/api/v1/certs/GIA/2224444063.pdf
        //http://api.checkgems.com/static/pdfjs/web/viewer.html?file=/api/v2/certs/GIA/2224444063.pdf  启用V2版本
        if (row.CertType && row.CertType != "") {
            if (row.CertNo && row.CertNo != "" && (row.CertType == "GIA" || row.CertType == "IGI")) {
                //var link = "<a href='http://www.checkgems.com/cert/" + row.CertType + "/" + row.CertNo + "' target='_blank' title='证书查询" + row.CertNo + "'>" + row.CertType + "</a>";//有查宝网logo的链接
                //var link = "<a href='http://api.checkgems.com/static/pdfjs/web/viewer.html?file=/api/v2/certs/" + row.CertType + "/" + row.CertNo + ".pdf' target='_blank' title='证书查询" + row.CertNo + "'>" + row.CertType + "</a>";//无查宝网logo的链接9-8
                var link = "<a href='/team/ViewCert?certType=" + row.CertType + "&certNo=" + row.CertNo + "' target='_blank' title='证书查询" + row.CertNo + "'>" + row.CertType + "</a>";
                return link;
            }
            else if (row.CertType == "HRD" || row.CertType == "NGTC" || row.CertType == "EGL") {
                return "<span title=\"" + row.CertType + "\">" + row.CertType + "</span>";
            }
            else if (row.CertType == "PARCEL") {
                return "<span title=\"PARCEL\">PARCEL</span>";//包货
            }
        }
        return "<span title=\"NN\">NN</span>";//无证书货-散货
    }

    //颜色：彩钻简写，白钻不变
    function ColorFormat(row) {

        var value = row.Color;//颜色Color
        var isFancyValue = row.IsFancy;//是否彩钻 1

        if (isFancyValue == 1) {
            if (value && value != "") {
                var tmp = value.replace(/\-/g, " ").replace(/\./g, " ");
                if (value.indexOf(",") > -1) {
                    var tmparr = value.split(",");
                    tmp = tmparr[0].length > tmparr[1].length ? tmparr[0] : tmparr[1];
                }
                var arr = tmp.split(" ");
                if (arr.length == 1) {
                    return "<span title='" + arr[0] + "'>" + arr[0].toUpperCase() + "</span>";
                }
                var col = [];
                for (var i = 0; i < arr.length; i++) {
                    col.push(arr[i][0]);
                }
                return "<span title='" + value.toUpperCase() + "'>" + col.join("").toUpperCase() + "</span>";
            }
            return "FANCY";
        }
        return value;
    }

    //日期时间格式化 03-09 dateTimeValue
    function DateTimeHandler(dateTimeValue) {
        if (dateTimeValue != null && dateTimeValue != "") {
            var timeStr = dateTimeValue.replace('T', ' ').replace(/-/g, '/'); //兼容firefox
            var hisTime = new Date(timeStr).getTime();
            if (!hisTime) { //数据库中可能为unicode时间
                timeStr = eval(dateTimeValue.replace(/\/(Date\([0-9-]+\))\//gi, 'new $1'));
                hisTime = new Date(timeStr).getTime();
            }
            var now = new Date().getTime(),
                diffValue = now - hisTime,
                result = '',
                minute = 1000 * 60,
                hour = minute * 60,
                day = hour * 24,
                halfamonth = day * 15,
                month = day * 30,
                year = month * 12,

                _year = diffValue / year,
                _month = diffValue / month,
                _week = diffValue / (7 * day),
                _day = diffValue / day,
                _hour = diffValue / hour,
                _min = diffValue / minute;

            if (_year >= 1) result = parseInt(_year) + "年前";
            else if (_month >= 1) result = parseInt(_month) + "月前";
            else if (_week >= 1) result = parseInt(_week) + "周前";
            else if (_day >= 1) result = parseInt(_day) + "天前";
            else if (_hour >= 1) result = parseInt(_hour) + "小时前";
            else if (_min >= 1) result = parseInt(_min) + "分钟前";
            else result = "刚刚";
            return result;
        } else {
            return '';
        }
    }

    //日期格式化（年-月-日）
    function YearDateFormat(dateValue) {

        if (dateValue != null) {

            var CurrentDate = "";

            var datetime = new Date(dateValue);

            var Year = datetime.getFullYear();
            var Month = datetime.getMonth() + 1;
            var Day = datetime.getDate();

            CurrentDate += Year + "-";

            if (Month >= 10) {
                CurrentDate += Month + "-";
            }
            else {
                CurrentDate += "0" + Month + "-";
            }

            if (Day >= 10) {
                CurrentDate += Day + " ";
            }
            else {
                CurrentDate += "0" + Day + " ";
            }

            if (CurrentDate == "01-01 00:00") {
                CurrentDate = "";
            }

            return CurrentDate;//08-09 20:39

        } else {
            return "-";
        }
    }
//已解决_IE8及以下浏览器日期时间兼容.txt  liu
    function DateFormat(dateValue) {
        if (!dateValue) return "-";

        var format = "MM-dd";
        var time1 = (dateValue + '').toString();
        dateValue = new Date(Date.parse(time1.replace(/-/g, "/").replace(/T|Z/g, ' ')));

        var o = {
            "M+": dateValue.getMonth() + 1, //月份
            "d+": dateValue.getDate(), //日
            "h+": dateValue.getHours(), //小时
            "m+": dateValue.getMinutes(), //分
            "s+": dateValue.getSeconds(), //秒
            "q+": Math.floor((dateValue.getMonth() + 3) / 3), //季度
            "S": dateValue.getMilliseconds() //毫秒
        };

        for (var k in o)
            if (new RegExp("(" + k + ")").test(format)) format = format.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));

        return format;
    }
//已解决_IE8及以下浏览器日期时间兼容.txt  liu
    //日期格式化（月-日 时:分）
    function DateTimeFormat(dateValue) {
        if (!dateValue) return "-";

        var format = 'MM-dd hh:mm';
        var time1 = (dateValue + '').toString();
        dateValue = new Date(Date.parse(time1.replace(/-/g, "/").replace(/T|Z/g, ' ')));

        var o = {
            "M+": dateValue.getMonth() + 1, //月份
            "d+": dateValue.getDate(), //日
            "h+": dateValue.getHours(), //小时
            "m+": dateValue.getMinutes(), //分
            "s+": dateValue.getSeconds(), //秒
            "q+": Math.floor((dateValue.getMonth() + 3) / 3), //季度
            "S": dateValue.getMilliseconds() //毫秒
        };

        for (var k in o)
            if (new RegExp("(" + k + ")").test(format)) format = format.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));

        return format;
    }


    //回到顶部
    function goTop() {
        $(window).scroll(function (e) {
            //若滚动条离顶部大于100元素
            if ($(window).scrollTop() > 100)
                $(".top_box").fadeIn(1000);//以1秒的间隔渐显class=top_box的元素
            else
                $(".top_box").fadeOut(1000);//以1秒的间隔渐隐class=top_box的元素
        });
    };

    $(function () {
        $(".cart_icon_out").hide();

        //全屏遮罩
        $(".all_loading_pic").css("top", $(window).height() / 2 - $(".all_loading_pic").height() / 2);
        $(".all_loading_pic").css("left", $(window).width() / 2 - $(".all_loading_pic").width() / 2);
        $(window).resize(function (event) {
            $(".all_loading_pic").css("top", $(window).height() / 2 - $(".all_loading_pic").height() / 2);
            $(".all_loading_pic").css("left", $(window).width() / 2 - $(".all_loading_pic").width() / 2);
        });

        //元素遮罩
        $(".loading_pic").css("left", $(".loading_pic_box").width() / 2 - $(".loading_pic").width() / 2);
        $(window).resize(function (event) {
            $(".loading_pic").css("left", $(".loading_pic_box").width() / 2 - $(".loading_pic").width() / 2);
        });

        //通知二级菜单
        $('.second_list').hover(function () {
            $(this).children('ol').show();
        }, function () {
            $(this).children('ol').hide();
        });

        //回到顶部
        $(".top_box").click(function (e) {            
            $('body,html').animate({ scrollTop: 0 }, 200);//以1秒的间隔返回顶部
        });
        goTop();//实现回到顶部元素的渐显与渐隐


        //位置调整
        var fawid = $(".fadeoutbox ").width();
        $(".fadeoutbox  ").css("top", $(window).height() / 2 - $(".fadeoutbox ").height() / 2);
        $(".fadeoutbox  ").css("left", $(window).width() / 2 - fawid / 2);
        $(window).resize(function (event) {
            $(".fadeoutbox ").css("top", $(window).height() / 2 - $(".fadeoutbox ").height() / 2);
            $(".fadeoutbox ").css("left", $(window).width() / 2 - fawid / 2);
        });

    });

    function isIE() { //判断是否是ie浏览器，到最新版本  
        if (!!window.ActiveXObject)
            return true;
        else
            return false;
    }

    //排序初始化（公用） 8-16
    $(function () {

        if (isIE() == true) {
            $("#header").css("height", "80px");
            $("#container").css("margin-top", "130px");
            $(".title").css("top", "85px");
            $(".left_menu").css("top", '80px');
            $(".brower_tips").show();
            $(".hide_left_menu").css("top", "80px");
            $(".hide_left_menu").css("top", "40px");
        }
        else { $(".brower_tips").hide(); }
        //关闭浏览器提醒
        $(".colse_brower_tips").click(function () {
            $(".brower_tips").hide();
            $("#header").css("height", "40px");
            $("#container").css("margin-top", "90px");
            $(".title").css("top", "40px");
            $(".left_menu").css("top", '40px');
        });        

        //收起左边菜单栏 9-23
        var z = 0;
        $(".left_menu").hover(function () {
            check_left_menu();
        });
        function check_left_menu() {
            if (z == 0) {
                $(".left_menu").stop().animate({ "left": 0 }, 200);
                //$(".title span").css("margin-left", "130px");
                z = 1;
            } else {
                $(".left_menu").stop().animate({ "left": -205 }, 200);
                //$(".title span").css("margin-left", "34px");
                z = 0;
            }
        }
     
       
    });
    
